import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import AutoImport from 'unplugin-auto-import/vite';
import Components from 'unplugin-vue-components/vite';
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers';

// 封装一个方法
import path from 'path';
let _resolve = dir => {
    return path.resolve(dir);
};

// https://vitejs.dev/config/
export default defineConfig({
    //plugins: [vue()],
    plugins: [
        // ...
        vue(),

        AutoImport({
            resolvers: [ElementPlusResolver()],
        }),
        Components({
            resolvers: [ElementPlusResolver()],
        }),
    ],
    server: {
        port: 5555,
        proxy: {
            '/api': {
                target: 'http://chst.vip',
                rewrite: path => path.replace(/^\/api/, ''),
            },
        },
    },
    resolve: {
        alias: {
            '@': _resolve('src'),
        },
    },
});
